package com.ruoyi.zsyh.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zsyh.domain.ZsyhFactoryBankcards;
import com.ruoyi.zsyh.service.IZsyhFactoryBankcardsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 厂家卡片管理Controller
 * 
 * @author yuexl
 * @date 2021-12-28
 */
@Controller
@RequestMapping("/zsyh/factoryBankCards")
public class ZsyhFactoryBankcardsController extends BaseController
{
    private String prefix = "zsyh/factoryBankCards";

    @Autowired
    private IZsyhFactoryBankcardsService zsyhFactoryBankcardsService;

    @RequiresPermissions("zsyh:factoryBankCards:view")
    @GetMapping()
    public String factoryBankCards()
    {
        return prefix + "/factoryBankCards";
    }

    /**
     * 查询厂家卡片管理列表
     */
    @RequiresPermissions("zsyh:factoryBankCards:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ZsyhFactoryBankcards zsyhFactoryBankcards)
    {
        startPage();
        List<ZsyhFactoryBankcards> list = zsyhFactoryBankcardsService.selectZsyhFactoryBankcardsList(zsyhFactoryBankcards);
        return getDataTable(list);
    }

    /**
     * 导出厂家卡片管理列表
     */
    @RequiresPermissions("zsyh:factoryBankCards:export")
    @Log(title = "厂家卡片管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ZsyhFactoryBankcards zsyhFactoryBankcards)
    {
        List<ZsyhFactoryBankcards> list = zsyhFactoryBankcardsService.selectZsyhFactoryBankcardsList(zsyhFactoryBankcards);
        ExcelUtil<ZsyhFactoryBankcards> util = new ExcelUtil<ZsyhFactoryBankcards>(ZsyhFactoryBankcards.class);
        return util.exportExcel(list, "厂家卡片管理数据");
    }

    /**
     * 新增厂家卡片管理
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存厂家卡片管理
     */
    @RequiresPermissions("zsyh:factoryBankCards:add")
    @Log(title = "厂家卡片管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ZsyhFactoryBankcards zsyhFactoryBankcards)
    {
        return toAjax(zsyhFactoryBankcardsService.insertZsyhFactoryBankcards(zsyhFactoryBankcards));
    }

    /**
     * 修改厂家卡片管理
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") String id, ModelMap mmap)
    {
        ZsyhFactoryBankcards zsyhFactoryBankcards = zsyhFactoryBankcardsService.selectZsyhFactoryBankcardsById(id);
        mmap.put("zsyhFactoryBankcards", zsyhFactoryBankcards);
        return prefix + "/edit";
    }

    /**
     * 修改保存厂家卡片管理
     */
    @RequiresPermissions("zsyh:factoryBankCards:edit")
    @Log(title = "厂家卡片管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ZsyhFactoryBankcards zsyhFactoryBankcards)
    {
        return toAjax(zsyhFactoryBankcardsService.updateZsyhFactoryBankcards(zsyhFactoryBankcards));
    }

    /**
     * 删除厂家卡片管理
     */
    @RequiresPermissions("zsyh:factoryBankCards:remove")
    @Log(title = "厂家卡片管理", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(zsyhFactoryBankcardsService.deleteZsyhFactoryBankcardsByIds(ids));
    }
}
